<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="org.apak.model.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Customer menu</title>
</head>
<body>
<form action="customerMenu?action=customerSearch" method="post">
	Name: <input type="text" name="name">
	<input type="submit" name="actionButton" value="Search"/>
<%
	Customer[] sortedCustomerArray = (Customer[]) request.getAttribute("sortedCustomerList");
	Customer[] customerArray = (Customer[]) request.getAttribute("customerList");
	if(customerArray != null) {
%>
		Customer list: <br />
		<table>
			<tr>
				<th>ID</th>
				<th>Customer name</th>
				<th>Type</th>
				<th>...</th>
			</tr>
<%
		int i;
		for(i = 0; i < customerArray.length; i++) {
%>
			<tr>
				<td><%= customerArray[i].getCustomer() %></td>
				<td><%= customerArray[i].getCustomerName() %></td>
				<td><%= customerArray[i].getTypeName() %></td>
				<td>
				<a href="./serviceRequest?customer=<%=customerArray[i].getCustomer()%>">Choose</a></td>
			</tr>
<%	
		}
%>
		</table>
<%	
	} else if(sortedCustomerArray != null) {
%>
		Customer list: <br />
		<table>
			<tr>
				<th>ID</th>
				<th>Customer name</th>
				<th>Type</th>
				<th>...</th>
			</tr>
<%
		int i;
		for(i = 0; i < sortedCustomerArray.length; i++) {
%>
			<tr>
				<td><%= sortedCustomerArray[i].getCustomer() %></td>
				<td><%= sortedCustomerArray[i].getCustomerName() %></td>
				<td><%= sortedCustomerArray[i].getTypeName() %></td>
				<td>
				<a href="./serviceRequest?customer=<%=sortedCustomerArray[i].getCustomer()%>">Choose</a></td>
			</tr>
<%	
		}
%>
		</table>
<%	
	}
%>
</form>
</body>
</html>